package com.zzjson.design.strategy.pay;

import com.zzjson.design.strategy.pay.payport.PayStrategy;
import com.zzjson.design.strategy.pay.payport.Payment;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : cn.zzjson.design.strategy.pay.payport</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年03月27日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class Order {
    private String uid;
    private String ordid;
    private double amount;

    public Order(String uid, String ordid, double amount) {
        this.uid = uid;
        this.ordid = ordid;
        this.amount = amount;
    }


    //完美地解决了switch的过程，不需要在代码逻辑中写switch了
    //更不需要写if    else if
    public MsgResult pay() {
        return pay(PayStrategy.DEFAULT_PAY);
    }

    public MsgResult pay(String payKey) {
        Payment payment = PayStrategy.get(payKey);
        System.out.println("欢迎使用" + payment.getName());
        System.out.println("本次交易金额为：" + amount + "，开始扣款...");
        return payment.pay(uid, amount);
    }
}